import type { LoginParams } from '@/types/user';
import request from '@/utils/http/index.ts';

/**
 * 登录
 * @param params
 * @returns
 */
export const login = (params: LoginParams) => request.post(`/login`, params);

export const logout = () => request.delete(`/logout`);

/**
 * 获取用户信息
 * @returns
 */
export const getUserInfo = () => request.get(`/getInfo`);

/**
 * 获取验证码
 * @returns
 */
export const getValideCode = () => request.get(`/captcha`);

/**
 * 获取路由
 * @returns
 */
export const getRoutes = () => request.get('/getRouters');

/**
 * 获取用户列表
 * @returns
 * */
export const getUserList = (params: any) => request.get('/user/list', { params });

/**
 * 修改用户状态
 * @param params
 * @returns
 */
export const changeUserStatus = (params: any) => request.put(`/user/changeStatus`, params);

/**
 * 查询用户详细
 * @param userId
 * @returns
 */
export const getUser = (userId: string = '') => request.get(`/user/${userId}`);

/**
 * 新增用户
 * @param params
 * @returns
 */
export const addUser = (params: any) => request.post(`/user`, params);

/**
 * 修改用户
 * @param params
 * @returns
 * */
export const updateUser = (params: any) => request.put(`/user`, params);

/**
 * 删除用户
 * @param userId
 * @returns
 * */
export const deleteUser = (userId: string) => request.delete(`/user/${userId}`);

/**
 * 重置密码
 * @param params
 * @returns
 */
export const resetPassword = (params: any) => request.put(`/user/resetPwd`, params);

/**
 * 获取用户对应的角色列表
 * @param userId
 * @returns
 */
export const getAuthRole = (userId: string) => request.get(`/user/authRole/${userId}`);

/**
 * 更新用户角色
 * @param params
 * @returns
 */
export const updateUserRole = (params: any) => request.put(`/user/authRole`, params);

/**
 * 个人中心用户详情
 * @returns
 */
export const getProfileInfo = () => request.get(`/user/profile`);

/**
 * 更新基本信息
 * @param params
 * @returns
 */
export const updateProfile = (params: any) => request.put(`/user/profile`, params);

/**
 * 上传头像
 * @param data
 * @returns
 */
export const updateProfileAvatar = (data: any) => request.post(`/user/profile/avatar`, data);

/**
 * 修改密码
 * @param params
 * @returns
 */
export const updateProfilePwd = (params: any) => request.put(`/user/profile/updatePwd`, params);
